/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.base.service.reader;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.base.entity.reader.BaseReader;
import com.thinkgem.jeesite.modules.base.dao.reader.BaseReaderDao;

/**
 * 基础管理_读者信息生成Service
 * @author 呆子
 * @version 2020-02-21
 */
@Service
@Transactional(readOnly = true)
public class BaseReaderService extends CrudService<BaseReaderDao, BaseReader> {

    @Autowired
    private BaseReaderDao baseReaderDao;

	public BaseReader get(String id) {
		return super.get(id);
	}
	
	public List<BaseReader> findList(BaseReader baseReader) {
		return super.findList(baseReader);
	}
	
	public Page<BaseReader> findPage(Page<BaseReader> page, BaseReader baseReader) {
		return super.findPage(page, baseReader);
	}
	
	@Transactional(readOnly = false)
	public void save(BaseReader baseReader) {
        super.save(baseReader);
	}
	
	@Transactional(readOnly = false)
	public void delete(BaseReader baseReader) {
		super.delete(baseReader);
	}

	public  List<BaseReader> queryAllReader(){
	    return baseReaderDao.queryAllReader();
    }

    public Boolean validReaderIdResult(BaseReader baseReader){
        List<BaseReader> baseReaders = queryAllReader();
        ArrayList<String> ReaderIds = new ArrayList<>();
        for (BaseReader reader : baseReaders) {
            ReaderIds.add(reader.getReaderId());
        }
        return ReaderIds.contains(baseReader.getReaderId());
    }
    public Boolean validReaderIDCardIdResult(BaseReader baseReader){
        List<BaseReader> baseReaders = queryAllReader();
        ArrayList<String> ReaderIDCardIds = new ArrayList<>();
        for (BaseReader reader : baseReaders) {
            ReaderIDCardIds.add(reader.getReaderIdcardId());
        }
        return ReaderIDCardIds.contains(baseReader.getReaderIdcardId());
    }
}